﻿ 

namespace com.iot.core.data
{
    public partial interface IBaseService<TEntity> where TEntity : BaseEntity
    {
        IRepository<TEntity> Repository { get; }

        IRepository<TEntity> BaseMapper { get; }//别名


        IQueryable<TEntity> GetAll(bool includeDeleted = false);
        Task<int> SaveChagnesAsync();
        int SaveChagnes();

        TEntity GetById(long id);
        Task<TEntity> GetByIdAsync(long id);

        List<TEntity> GetByIds(List<long> lid);
        Task<List<TEntity>> GetByIdsAsync(List<long> lid);



        int Insert(TEntity entity, bool autoField = true,bool autoSave=true);
        Task<int>InsertAsync(TEntity entity, bool autoField = true, bool autoSave = true);

        int Insert(List<TEntity> lentity, bool autoField = true, bool autoSave = true);
        Task<int> InsertAsync(List<TEntity> lentity, bool autoField = true, bool autoSave = true);


        int Update(TEntity entity, bool autoField = true, bool autoSave = true);
        Task<int> UpdateAsync(TEntity entity, bool autoField = true, bool autoSave = true);

        int Delete(TEntity entity, bool autoField = true, bool autoSave = true);
        Task<int> DeleteAsync(TEntity entity, bool autoField = true, bool autoSave = true);
        int Delete(BaseQto qm);


        int DeleteById(long Id, bool autoField = true, bool autoSave = true);
        Task<int> DeleteByIdAsync(long Id, bool autoField = true, bool autoSave = true);

        int DeleteByIds(List<long> lId, bool autoField = true, bool autoSave = true);
        Task<int> DeleteByIdsAsync(List<long> lId, bool autoField = true, bool autoSave = true);

        List<T> QueryToList<T>(string sql, int CommandTimeout = 30) where T : new();
        List<IdNameDto> QueryName(List<long> lid, string tbname = "", string namefiled = "");
        string GetName(long id, string tbname = "", string namefiled = "");

        void EntityToDto(object src, object dst);
        void DtoToEntity(object src, object dst);
    }
}
